package org.wu.framework.authorization.platform.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.authorization.platform.application.SysDictionaryApplication;
import org.wu.framework.authorization.platform.application.command.SysDictionaryCommand;
import org.wu.framework.authorization.platform.infrastructure.entity.SysDictionaryDO;
import org.wu.framework.authorization.platform.domain.model.sys.dictionary.SysDictionary;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController;
import org.wu.framework.lazy.orm.web.plus.AbstractLazyCrudProvider;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.spring.EasyController;

import java.util.List;

/**
 * describe
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyController
 **/
@Tag(name = "提供者")
@EasyController("/dictionary")
public class SysDictionaryProvider extends AbstractLazyCrudProvider<SysDictionaryDO, SysDictionaryDO, Long> {

    @Autowired
    private SysDictionaryApplication sysDictionaryApplication;

    /**
     * describe 新增
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @PostMapping("/story")
    public Result<SysDictionary> story(@RequestBody SysDictionaryCommand sysDictionaryCommand) {
        return sysDictionaryApplication.save(sysDictionaryCommand);
    }

    /**
     * describe 更新
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @PutMapping("/updateOne")
    public Result<SysDictionary> updateOne(@RequestBody SysDictionaryCommand sysDictionaryCommand) {
        return sysDictionaryApplication.update(sysDictionaryCommand);
    }

    /**
     * describe 查询单个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @GetMapping("/findOne")
    public Result<SysDictionary> findOne(@ModelAttribute SysDictionaryCommand sysDictionaryCommand) {
        return sysDictionaryApplication.findOne(sysDictionaryCommand);
    }

    /**
     * describe 查询多个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @GetMapping("/findList")
    public Result<List<SysDictionary>> findList(@ModelAttribute SysDictionaryCommand sysDictionaryCommand) {
        return sysDictionaryApplication.findList(sysDictionaryCommand);
    }

    /**
     * describe 删除
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @DeleteMapping("/delete")
    public Result<SysDictionary> delete(@ModelAttribute SysDictionaryCommand sysDictionaryCommand) {
        return sysDictionaryApplication.delete(sysDictionaryCommand);
    }
}